﻿// ***********************************************************************
// Assembly         : STX.Admin
// Author           : seven.x
// Created          : 12-26-2013
//
// Last Modified By : seven.x
// Last Modified On : 12-26-2013
// ***********************************************************************
// <copyright file="AdminAreaRegistration.cs" company="驰创数码">
//     Copyright (c) 驰创数码. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Web.Mvc;
using STX.Lib.Utils;

namespace STX.Admin
{
    /// <summary>
    /// Class AdminAreaRegistration.
    /// </summary>
    public class AdminAreaRegistration : AreaRegistration
    {
        // ReSharper disable once InconsistentNaming
        /// <summary>
        /// The _area name
        /// </summary>
        private static readonly string _areaName = "Admin";
        /// <summary>
        /// Initializes static members of the <see cref="AdminAreaRegistration"/> class.
        /// </summary>
        static AdminAreaRegistration()
        {
            var areaName = STXConfig.GetValue("/config/app/administratorPath");
            if (!areaName.IsNullOrEmpty())
            {
                _areaName = areaName;
            }
        }
        /// <summary>
        /// 获取要注册的地方的名称。
        /// </summary>
        /// <value>The name of the area.</value>
        /// <returns>要注册的地方的名称。</returns>
        public override string AreaName
        {
            get
            {
                return _areaName;
            }
        }

        /// <summary>
        /// 使用指定地方的上下文信息在 ASP.NET MVC 应用程序内注册某个地方。
        /// </summary>
        /// <param name="context">对注册地方所需的信息进行封装。</param>
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                _areaName+"_default",
                _areaName + "/{controller}/{action}/{id}",
                new { controller = "Login", action = "Index", area = _areaName, id = UrlParameter.Optional },
                new[] { "STX.Admin.Controllers" }
            );
        }
    }
}
